home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1994 June / PC Plus Super CD coverdisc Issue 93 June 1994.iso / suprdisk / button / directry.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-04-12  |  6.9 KB  |  241 lines

  1. VERSION 2.00
  2. Begin Form Directory 
  3.    BackColor       =   &H00FFFFFF&
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "Open"
  6.    ClientHeight    =   3795
  7.    ClientLeft      =   1545
  8.    ClientTop       =   1965
  9.    ClientWidth     =   6210
  10.    ControlBox      =   0   'False
  11.    FillStyle       =   3  'Vertical Line
  12.    FontBold        =   -1  'True
  13.    FontItalic      =   0   'False
  14.    FontName        =   "System"
  15.    FontSize        =   9.75
  16.    FontStrikethru  =   0   'False
  17.    FontUnderline   =   0   'False
  18.    Height          =   4200
  19.    Icon            =   0
  20.    Left            =   1485
  21.    LinkMode        =   1  'Source
  22.    LinkTopic       =   "Form1"
  23.    MaxButton       =   0   'False
  24.    MinButton       =   0   'False
  25.    ScaleHeight     =   3795
  26.    ScaleWidth      =   6210
  27.    Top             =   1620
  28.    Width           =   6330
  29.    Begin FileListBox File1 
  30.       Height          =   1980
  31.       Left            =   2700
  32.       Pattern         =   "*.txt"
  33.       TabIndex        =   2
  34.       Top             =   1260
  35.       Width           =   1785
  36.    End
  37.    Begin DirListBox Dir1 
  38.       Height          =   1605
  39.       Left            =   450
  40.       TabIndex        =   5
  41.       Top             =   1260
  42.       Width           =   2100
  43.    End
  44.    Begin CommandButton Command1 
  45.       Caption         =   "&Refresh"
  46.       Height          =   420
  47.       Left            =   4650
  48.       TabIndex        =   10
  49.       Top             =   1305
  50.       Width           =   1140
  51.    End
  52.    Begin CommandButton cmdOk 
  53.       Caption         =   "OK"
  54.       Default         =   -1  'True
  55.       Height          =   420
  56.       Left            =   4650
  57.       TabIndex        =   8
  58.       Top             =   2070
  59.       Width           =   1125
  60.    End
  61.    Begin TextBox text1 
  62.       Height          =   345
  63.       Left            =   1530
  64.       TabIndex        =   1
  65.       Text            =   "*.txt"
  66.       Top             =   795
  67.       Width           =   4140
  68.    End
  69.    Begin CommandButton cmdCancel 
  70.       Cancel          =   -1  'True
  71.       Caption         =   "Cancel"
  72.       Height          =   420
  73.       Left            =   4650
  74.       TabIndex        =   9
  75.       Top             =   2790
  76.       Width           =   1125
  77.    End
  78.    Begin DriveListBox drvDrives 
  79.       Height          =   315
  80.       Left            =   450
  81.       TabIndex        =   7
  82.       Top             =   2925
  83.       Width           =   2100
  84.    End
  85.    Begin Label lblFileName 
  86.       BackStyle       =   0  'Transparent
  87.       Caption         =   "File &Name:"
  88.       Height          =   240
  89.       Left            =   480
  90.       TabIndex        =   0
  91.       Top             =   870
  92.       Width           =   975
  93.    End
  94.    Begin Label lblDirectories 
  95.       BackStyle       =   0  'Transparent
  96.       Caption         =   "&Directory:"
  97.       Height          =   240
  98.       Left            =   480
  99.       TabIndex        =   3
  100.       Top             =   405
  101.       Width           =   885
  102.    End
  103.    Begin Label lblCurrentDir 
  104.       BackStyle       =   0  'Transparent
  105.       Height          =   225
  106.       Left            =   1530
  107.       TabIndex        =   4
  108.       Top             =   420
  109.       Width           =   4140
  110.    End
  111.    Begin Label lblDrives 
  112.       BackStyle       =   0  'Transparent
  113.       Caption         =   "Dri&ves:"
  114.       Height          =   255
  115.       Left            =   3555
  116.       TabIndex        =   6
  117.       Top             =   2820
  118.       Width           =   765
  119.    End
  120. Const FILECLICK = False
  121. Const DIRCLICK = 1
  122. Dim LastClick As Integer
  123. Sub cmdCancel_Click ()
  124.     ' Set the file name text box to null.
  125.     ' By checking the text property of this text box,
  126.     ' other procedures can tell if Cancel has been
  127.     ' selected.
  128.     Directory.text1 = ""
  129.     '
  130.     ' Hide the form
  131.     Directory.Hide
  132. End Sub
  133. Sub cmdOK_Click ()
  134. Dim Msg As String
  135. On Error Resume Next
  136.     If LastClick = DIRCLICK Then
  137.         Dir1.Path = Dir1.List(Dir1.ListIndex)
  138.         Exit Sub
  139.     End If
  140.     On Error Resume Next
  141.     'if a full path has been entered in the text box then
  142.     'set the directory label to ""
  143.     If InStr(text1, "\") Then
  144.         lblCurrentDir = ""
  145.     Else
  146.         GroupName = Left$(text1, InStr(text1, "_") - 1)
  147.     End If
  148.     If Left$(text1, 1) = "*" Then Error 64
  149.     If Len(lblCurrentDir) <> 0 Then
  150.         If Right$(lblCurrentDir, 1) = "\" Then
  151.             text1 = lblCurrentDir & text1
  152.         Else
  153.             text1 = lblCurrentDir & "\" & text1
  154.         End If
  155.     End If
  156.     If Err Then
  157.         MsgBox Error$, 0, Temp$
  158.         text1.SelStart = 0
  159.         text1.SelLength = Len(text1)
  160.     Else
  161.         Directory.Hide
  162.     End If
  163. End Sub
  164. Sub Command1_Click ()
  165.     drvDrives.Refresh
  166.     Dir1.Refresh
  167.     file1.Refresh
  168. End Sub
  169. Sub Dir1_Change ()
  170.     ' propogate directory changes to other controls
  171.     file1.Path = Dir1.Path
  172.     lblCurrentDir.Caption = Dir1.Path
  173.     text1 = file1.Pattern
  174.     file1.SetFocus
  175. End Sub
  176. Sub Dir1_Click ()
  177.     LastClick = DIRCLICK
  178. End Sub
  179. Sub drvDrives_Change ()
  180.     ' change the Dir1 control path, it will
  181.     ' pass the change on to the File1 control
  182.     Dir1.Path = drvDrives.Drive
  183.     ChDrive (drvDrives.Drive)
  184. End Sub
  185. Sub File1_Click ()
  186.     ' echo the selected name in the Text box
  187.     LastClick = FILECLICK
  188.     text1 = file1.FileName
  189. End Sub
  190. Sub File1_DblClick ()
  191.     ' we have a final selection from the File Save dialog
  192.     'text1 = File1.FileName
  193.     cmdOK_Click
  194. End Sub
  195. Sub File1_PathChange ()
  196.     Dir1.Path = file1.Path
  197.     drvDrives.Drive = file1.Path
  198. End Sub
  199. Sub File1_PatternChange ()
  200.     'Show the current search pattern in the text1 control
  201.     text1 = file1.Pattern
  202.     Dir1.Path = file1.Path
  203. End Sub
  204. Sub Form_Activate ()
  205.     If Len(CurrentDirectory) > 0 Then Dir1.Path = CurrentDirectory
  206.     ' initialize file controls
  207.     file1.Refresh
  208.     file1.Pattern = "*_B.DAT"
  209.     text1 = file1.Pattern
  210.     Directory.text1.SelStart = 0
  211.     Directory.text1.SelLength = Len(Directory.text1)
  212.     HelpItem = 14
  213. End Sub
  214. Sub Form_KeyDown (KeyCode As Integer, Shift As Integer)
  215.     If KeyCode = &H70 Then Cheap_Help Format$(HelpItem)
  216. End Sub
  217. Sub Form_Load ()
  218.     Position_Form Directory
  219.     lblCurrentDir.Caption = Dir1.Path
  220.     KeyPreview = True
  221. End Sub
  222. Sub Form_QueryUnload (Cancel As Integer, UnloadMode As Integer)
  223.     cmdCancel_Click
  224.     Cancel = True
  225. End Sub
  226. Sub Form_Unload (Cancel As Integer)
  227.     'Cancel = True   ' Don't unload form, just hide it
  228.     'Call cmdCancel_Click
  229. End Sub
  230. Sub Text1_Change ()
  231.     ' Disable OK button if no filename.
  232.     cmdOK.Enabled = (Len(text1) > 0)
  233. End Sub
  234. Sub text1_GotFocus ()
  235.     text1.SelStart = 0
  236.     text1.SelLength = Len(text1)
  237. End Sub
  238. Sub Text1_KeyPress (KeyAscii As Integer)
  239.     LastClick = FILECLICK
  240. End Sub
  241.